home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cmdline.lha / cmdline / src / lib / states.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-13  |  2.6 KB  |  84 lines

  1. //------------------------------------------------------------------------
  2. // ^FILE: states.h - state definitions for the CmdLine library
  3. //
  4. // ^DESCRIPTION:
  5. //     This file contains the definitions for the various values of the
  6. //  state and parse-state of a command-line object. It also contains
  7. //  any definitions that are dependent upon the command-line syntax
  8. //  (i.e. unix_style or vms_style).
  9. //
  10. // ^HISTORY:
  11. //    03/26/92    Brad Appleton    <brad@ssd.csd.harris.com>    Created
  12. //-^^---------------------------------------------------------------------
  13.  
  14. #ifndef _states_h
  15. #define _states_h
  16.  
  17. #include "cmdline.h"
  18.  
  19. #ifdef unix_style
  20.    // Default command-flags for a unix-command
  21.    static const unsigned DEFAULT_CMDFLAGS = CmdLine::OPTS_FIRST ;
  22. #endif
  23.  
  24. #ifdef vms_style
  25.    // Default command-flags for a vms-command
  26.    static const unsigned DEFAULT_CMDFLAGS = CmdLine::TEMP ;
  27. #endif
  28.  
  29. //
  30. // cmd_state_t -- Define the bitmasks used to record the command state
  31. //
  32. enum cmd_state_t {
  33.    cmd_END_OF_OPTIONS  = 0x01,  // no more options/keywords?
  34.    cmd_OPTIONS_USED    = 0x02,  // were options used on cmdline?
  35.    cmd_KEYWORDS_USED   = 0x04,  // were keywords used on cmdline?
  36.    cmd_GUESSING        = 0x08,  // are we currently trying to guess?
  37. } ;
  38.  
  39. //
  40. // cmd_parse_state_t -- Define the possible parse-states for the command
  41. //
  42. // We use "START_STATE" to reset the state. Only one of the NEED*
  43. // states may be set at a time. For any of the NEED* states, TOK_REQUIRED
  44. // may or may not be set. TOK_REQUIRED should NOT be set if none of the
  45. // NEED* states is set.
  46. //
  47. // Note: we have the "states" set up so that one can test for WANT or NEED
  48. // by a bitwise & with a WANT flag. One can test if the particular "WANT"
  49. // is truly "NEEDED" by a bitwise & with the TOK_REQUIRED_FLAG. For
  50. // convenience, each WANT_XXX that is truly REQUIRED may also be
  51. // represented by NEED_XXX.
  52. //
  53. enum cmd_parse_state_t {
  54.    cmd_START_STATE  = 0x00,  // start-state (this MUST be 0)
  55.  
  56.    cmd_TOK_REQUIRED = 0x01,  // is the "wanted" token required?
  57.  
  58.    cmd_WANT_VAL     = 0x02,  // are we expecting a value?
  59. #ifndef __gplusplus
  60.    cmd_NEED_VAL     = (cmd_WANT_VAL | cmd_TOK_REQUIRED),
  61. #else
  62.    cmd_NEED_VAL     = 0x03,
  63. #endif
  64.  
  65. #ifdef vms_style
  66.    cmd_WANT_VALSEP  = 0x04,  // are we expecting ':' or '='
  67. # ifndef __gplusplus
  68.    cmd_NEED_VALSEP  = (cmd_WANT_VALSEP | cmd_TOK_REQUIRED),
  69. # else
  70.    cmd_NEED_VALSEP  = 0x05,
  71. # endif
  72.  
  73.    cmd_WANT_LISTSEP = 0x08,  // are we expecting ',' or '+'
  74. # ifndef __gplusplus
  75.    cmd_NEED_LISTSEP = (cmd_WANT_LISTSEP | cmd_TOK_REQUIRED),
  76. # else
  77.    cmd_NEED_LISTSEP = 0x09,
  78. # endif
  79. #endif
  80. } ;
  81.  
  82.  
  83. #endif /* _states_h */
  84.